/*
 * This file is part of WebCL – JavaScript bindings for OpenCL
 * http://webcl.nokiaresearch.com/
 *
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 *
 * Contact: Jari Nikara  ;jari.nikara@nokia.com;
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 *
 * The package is based on a published Khronos OpenCL 1.1 Specification,
 * see http://www.khronos.org/opencl/.
 *
 * OpenCL is a trademark of Apple Inc.
 */

#ifndef _WEBCL_MEMORYOBJECT_H_
#define _WEBCL_MEMORYOBJECT_H_

#include "WebCLCommon.h"
#include "IWebCLMemoryObject.h" // Generated from IWebCLMemoryObject.idl
#include "instance_registry.h"

#include <CL/opencl.h>


#define WEBCL_MEMORYOBJECT_CLASSNAME "WebCLMemoryObject"
#define WEBCL_MEMORYOBJECT_CID { 0xe677e482, 0x49e5, 0x40de, { 0xba, 0x4f, 0x0e, 0x71, 0xf3, 0x01, 0x28, 0x6b } }
#define WEBCL_MEMORYOBJECT_CONTRACTID "@webcl.nokiaresearch.com/WebCLMemoryObject;1"

/** Implements IWebCLMemoryObject interface. */
class WebCLMemoryObject : public IWebCLMemoryObject, public WebCLCommon
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSISECURITYCHECKEDCOMPONENT
  NS_DECL_IWEBCLMEMORYOBJECT

  static nsresult getInstance (cl_mem aInternal, WebCLMemoryObject** aResultOut,
                               WebCL_LibCLWrapper* aLibWrapper = 0);

  WebCLMemoryObject ();
  cl_mem getInternal () { return mInternal; }

protected:
  int getTypeForInfoName (int aName);

private:
  static InstanceRegistry<cl_mem, WebCLMemoryObject*> instanceRegistry;

  ~WebCLMemoryObject ();

  cl_mem mInternal;
};

#endif // _WEBCL_MEMORYOBJECT_H_
